package com.ruoyi.carShopService.service.impl;

import com.ruoyi.carShopService.domain.ShopUserDto;
import com.ruoyi.carShopService.mapper.FindShopUserMapper;
import com.ruoyi.carShopService.service.FindShopUserService;
import com.ruoyi.system.api.domain.CarMerchant;
import com.ruoyi.system.api.domain.CarMerchantPrincipal;
import com.ruoyi.system.api.domain.CarMerchantVerification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class FindShopUserServiceImpl implements FindShopUserService {

    @Autowired
    private FindShopUserMapper findShopUserMapper;
    @Override
    public ShopUserDto findShopUser(Long id) {
        CarMerchant carMerchant = findShopUserMapper.findCarMerchantById(id);
        CarMerchantPrincipal carMerchantPrincipalById = findShopUserMapper.findCarMerchantPrincipalById(id);
        CarMerchantVerification carMerchantVerificationById = findShopUserMapper.findCarMerchantVerificationById(id);
        ShopUserDto shopUserDto = new ShopUserDto();
        //商家信息简介
        shopUserDto.setMessage(carMerchant.getMerIntroduction());
        //商家营业执照id
        shopUserDto.setShopId(carMerchantVerificationById.getMerLicenseNumber());
        //商家营业执照图片
        List<String> strings = Arrays.stream(carMerchantVerificationById.getMerLicenseImage().split(",")).toList();
        shopUserDto.setFormFileList2(strings);
        //商家法人身份证照片
        shopUserDto.setFormFileList1(Arrays.asList(carMerchantPrincipalById.getIdCardFront(), carMerchantPrincipalById.getIdCardBack()));
        //商家法人手机号
        shopUserDto.setPhone(carMerchantPrincipalById.getPhoneNumber());
        //身份证号
        shopUserDto.setIdNum(carMerchantPrincipalById.getIdNumber());
        //法人姓名
        shopUserDto.setName(carMerchantPrincipalById.getPcpName());
        //商家详细地址
        shopUserDto.setShopHome(carMerchant.getMerAddress());
        //商家地区
        shopUserDto.setShopAddress(carMerchant.getMerArea());
        //商家店名
        shopUserDto.setShopName(carMerchant.getMerName());
        //商户照片
        shopUserDto.setFormFileList3(Arrays.stream(carMerchant.getImgPath().split(",")).toList());
        return shopUserDto;
    }
}
